fix(statewrite): preserve unmodeled manifest config across state writes#371
Merged
Merged
Conversation
Every state-write path (reset, rollback, promote, hotfix finalize) loaded the manifest, mutated the typed CICDFile, and re-marshaled the whole struct, silently dropping any key the running binary does not model. config.drift_check and any unmodeled or future field were lost on a state write, exactly as #350 reported. Add a shared WriteManifestState helper that parses the manifest into a yaml.Node and replaces only the state and latest_release children, preserving config, unmodeled siblings, unmodeled top-level keys, and comments verbatim. Route all six lossy sites through it. No public schema change. Closes #350. Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
d4f2a9c to
1fce499
Compare
joshua-temple
added a commit
that referenced
this pull request
Jun 27, 2026
…WriteManifestState (#389) orchestrate writeConfig and external writeManifest re-marshaled the typed CICDFile, dropping any manifest config the running binary does not model (and writeConfig dropped the ci: wrapper). This is the last lossy state-write class after #350/#371: it strips cli_version_sha (added in #384) on the next state commit for a binary that predates it, leaving a pin_mode:sha repo with SHA-pinned workflows but a manifest that no longer declares the pin, which reads as permanent drift and would re-open the setup-cli code-scanning alerts. Route both writers through config.WriteManifestState so only state and latest_release change and all other config, modeled or not, survives verbatim. Closes #372. Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (#350)
Every state-write path (reset, rollback, promote, hotfix finalize) re-marshaled the typed
CICDFilestruct, silently dropping any manifest key the running binary does not model.config.drift_checkand any unmodeled or future field were lost on a state write.Fix
New
internal/confighelperWriteManifestStateparses the manifest into ayaml.Nodeand replaces only thestateandlatest_releasechildren, preserving config, unmodeled siblings/top-level keys, and comments verbatim. All six lossy sites route through it. The generated-workflow yq path was already byte-safe and is unchanged. No public schema change.Tests
New
internal/config/statemerge_test.goproves unmodeled top-level, config-level (drift_check shape), and nested keys survive a state write while stale state is cleared;reset_test.goasserts an unmodeledfuture_knobsurvives a reset. Fullgo test ./...1955 pass; lint clean. Closes #350.